package com.airlines.runlimit.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.airlines.common.Page;
import com.airlines.runlimit.dao.SchMatchMapper;
import com.airlines.runlimit.domain.SchMatch;
import com.airlines.runlimit.domain.Schconflict;
import com.airlines.runlimit.service.SchMatchService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
/**
 * 人员搭配Service层
 * @Description:
 * @author ouwen
 * @Date 2018年9月18日
 */
@Service("schMatchService")
public class SchMatchServiceImpl implements SchMatchService {

	/**
	 * 人员搭配dao接口
	 */
	@Resource
	private SchMatchMapper schMatchMapper;
	
	/**
	 * 条件查询分页数据
	 * @param SchMatch
	 * @param page
	 * @return
	 */
	@Override
	public Page list(SchMatch schMatch, Page page) {
		PageHelper.startPage(page.getPageNumber(), page.getPageSize());
		List<Schconflict> list = schMatchMapper.listByQuery(schMatch);
		PageInfo<Schconflict> pageInfo = new PageInfo<Schconflict>(list);
		System.out.println(list);
		page.setTotal(String.valueOf(pageInfo.getTotal()));
		page.setRows(pageInfo.getList()); 
		return page;
	}
	
	/**
	 * 数据库新增一个数据
	 * @param SchMatch
	 * @return
	 */
	@Override
	public int insertOne(SchMatch schMatch) {
		return schMatchMapper.insertOne(schMatch);
	}

}
